/*

Copyright (C) 2007 Thomas Geiger (tom.geiger@gmail.com)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*/

#ifndef GLOBUSXIOCLIENT_H_
#define GLOBUSXIOCLIENT_H_

#include <iostream>
#include <sstream>

#include <globus_xio.h>
#include <globus_xio_gridftp_driver.h>
#include <globus_xio_http.h>

// security
#include <globus_xio_gsi.h>

#include "GlobusURL.h"

namespace globus_xio {

using namespace globus_common;

static const int BUF_SIZE = 256;

class GlobusXIOClient
{
	private:
		GlobusURL* 			url;
	    globus_xio_stack_t  stack;
	    globus_xio_driver_t driver;
	    globus_xio_attr_t   attr;    
	    globus_xio_handle_t handle;	
	    void test_error(globus_result_t res, int line);	
	protected:
		void initDriver(GlobusURL*);	
	public:
		GlobusXIOClient();
		virtual ~GlobusXIOClient();
		void receive(iostream&);
		void send(iostream&);
		void setUrl(GlobusURL*);
		GlobusURL* getUrl();
		// TODO: implement async operation
		//void abort();
		// TODO: support setting of attributes
		//void setAttribute();
};

}

#endif /*GLOBUSXIOCLIENT_H_*/
